<?php
namespace App\Services;

use App\Catgory;
use App\Attribute;
use App\Value;
use Illuminate\Http\Request;
use zgldh\QiniuStorage\QiniuStorage;

class  ImgUploade{

    public static function Getdate($data){
        $month=date('Y-m');
        $date='/'.$month.'/';
        return $date;
    }
    public static function uploadFile($file,$dir){

        $disk = QiniuStorage::disk('qiniu');

        $fileName = md5($file->getClientOriginalName().time().rand()).'.'.$file->getClientOriginalExtension();
        // 上传到七牛
        $bool = $disk->put($dir.$fileName,file_get_contents($file->getRealPath()));

        // 判断是否上传成功
        if ($bool)
        {
            $path = $disk->downloadUrl($dir.$fileName);
            return $path;
        }
        return "上传失败";
    }
}